package com.zahb.qadx.ui.adapter;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseMultiItemQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.zahb.qadx.R;
import com.zahb.qadx.model.ExamBean;

import org.jetbrains.annotations.NotNull;

import java.util.List;


public class ExamAdapter extends BaseMultiItemQuickAdapter<ExamBean, BaseViewHolder> {


    public ExamAdapter(@Nullable List<ExamBean> data) {
        super( data);

        addItemType(ExamBean.TITLE, R.layout.item_exam_title);
        addItemType(ExamBean.ITEM, R.layout.item_exam_item);

    }
    @Override
    protected void convert(@NotNull BaseViewHolder baseViewHolder, ExamBean examBean) {


        if(examBean.getItemType() == ExamBean.TITLE){
            baseViewHolder.setText(R.id.tv,examBean.title);
        }else{
            baseViewHolder.setText(R.id.tvName,examBean.name)
                    .setText(R.id.tvContent,examBean.content);

            if(examBean.colorType==0){
                baseViewHolder.setTextColorRes(R.id.tvName, R.color.blue)
                        .setTextColorRes(R.id.tvContent, R.color.blue);
            }else{
                baseViewHolder.setTextColorRes(R.id.tvName, R.color.text_color)
                        .setTextColorRes(R.id.tvContent, R.color.text_color);
            }
        }
    }
}
